var __importDefault =
    (this && this.__importDefault) ||
    ((mod) => (mod?.__esModule ? mod : { default: mod }));
Object.defineProperty(exports, "__esModule", { value: true });
const parser_1 = require("@babel/parser");
const _fs_1 = __importDefault(require("node:fs"));
const deobfuscator_1 = require("./deobfuscator");
const { defaultConfig } = require("./transformations/config");
// needed for webpack
globalThis.parser = {
    parse: parser_1.parse,
    parseExpression: parser_1.parseExpression,
};

function deobfuscate(
    source,
    sourceType = "unambiguous",
    config = { silent: true },
) {
    config = Object.assign(defaultConfig, config);
    const ast = (0, parser_1.parse)(source, { sourceType });
    const deobfuscator = new deobfuscator_1.Deobfuscator(ast, config);
    const output = deobfuscator.execute();
    return output;
}

module.exports = {
    deobfuscate,
};
